﻿using System;
using System.Collections.Generic;
using System.IO;

namespace TubeFile
{
    class Program
    {
        static void Main(string[] args)
        {
            string searchPath = @"D:\管道模型\有问题的";
            string aimPath = @"D:\管道模型\管道图纸按区域分";

            List<FileInfo> files = new List<FileInfo>();
            files = Handle.GetAllFiles(searchPath);

            foreach (FileInfo f in files)
            {
                if (f.Extension == ".dgn")
                {
                    try
                    {
                        int indexNumber = f.Name.IndexOf("KK2") + 3;
                        string temp = f.Name.Substring(indexNumber, 1);
                        string fileArea;
                        if (temp == "N")
                        {
                            fileArea = f.Name.Substring(indexNumber + 1, 3);
                        }
                        else
                        {
                            fileArea = f.Name.Substring(indexNumber, 3);
                        }
                        string fullFileArea = aimPath + Path.DirectorySeparatorChar + fileArea;
                        if (!Directory.Exists(fullFileArea))//如果不存在就创建file文件夹　　             　　              
                            Directory.CreateDirectory(fullFileArea);//创建该文件夹　　
                        f.MoveTo(fullFileArea + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(f.FullName).ToUpper() + f.Extension);
                        Console.WriteLine(f.Name);
                        Console.WriteLine(fileArea);
                    }
                    catch (Exception)
                    {


                    }

                }




            }
            Console.ReadLine();
        }
    }
}
